cmake_minimum_required(VERSION 3.16)

project(YOLOV5
        LANGUAGES CXX)

# toolchain.cmake

# Specify the cross compiler
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)

# Specify the cross compiler paths
set(CMAKE_C_COMPILER /opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-gcc)
set(CMAKE_CXX_COMPILER /opt/hisi-linux/x86-arm/arm-himix200-linux/bin/arm-himix200-linux-g++)
set(CMAKE_SYSROOT /opt/hisi-linux/x86-arm/arm-himix200-linux/host_bin/../target)

# Optionally specify additional compiler flags
set(CMAKE_C_FLAGS "--sysroot=${CMAKE_SYSROOT}")
set(CMAKE_CXX_FLAGS "--sysroot=${CMAKE_SYSROOT}")

set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/home/lulu/H_wp/Modules/")


find_library(V4L2_LIB v4l2)
find_package(JPEG REQUIRED)
find_package(OpenCV REQUIRED)

if(OpenCV_FOUND)
    message(STATUS "OpenCV found: ${OpenCV_DIR}")
    message(STATUS "OpenCV version: ${OpenCV_VERSION}")
    message(STATUS "OpenCV include directories: ${OpenCV_INCLUDE_DIRS}")
    message(STATUS "OpenCV library directories: ${OpenCV_LIBRARY_DIRS}")
    message(STATUS "OpenCV libraries: ${OpenCV_LIBS}")
endif()

# find_package(Eigen3 REQUIRED)
# find_package(FFTW REQUIRED)
# include_directories(${EIGEN3_INCLUDE_DIR})
# include_directories(${FFTW_INCLUDE_DIR})

add_library(V4l2Camera SHARED /home/lulu/H_wp/include/V4l2Camera.cpp /home/lulu/H_wp/include/V4l2Camera.h)
add_library(UDPimg SHARED /home/lulu/H_wp/include/UDPimg.cpp /home/lulu/H_wp/include/UDPimg.h)
# add_library(KCF SHARED /home/lulu/H_wp/include/KCF.cpp /home/lulu/H_wp/include/KCF.h)

target_link_libraries(V4l2Camera PUBLIC ${V4L2_LIB} ${JPEG_LIBRARIES} ${OpenCV_LIBS})
target_link_libraries(UDPimg PUBLIC V4l2Camera)
# target_link_libraries(KCF PUBLIC UDPimg ${FFTW_LIBRARIES})

# Specify the include directories
include_directories(/home/lulu/H_wp/include)

# Specify output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

# exe
# add_executable(V4l2_demo /home/lulu/H_wp/main/V4l2_demo.cpp)
# target_link_libraries(V4l2_demo pthread)

add_executable(kcf /home/lulu/H_wp/main/opencv_tracker.cpp)
target_link_libraries(kcf pthread UDPimg)

add_executable(_kcf /home/lulu/H_wp/main/track_framse.cpp)
target_link_libraries(_kcf pthread UDPimg)
